<?php 

/**
 * 货品列表模型
 */

class ListModel extends Model{
	
	public $table = 'goods_list';
	
	public $auto = array(
		array('spec','_spec','method',2,3),
	);
	
	public function _spec($value){
	    $value = implode(',', $value);
		return $value;
	}
	
	
	public $validate = array(
		array('number','nonull','货品货号不能为空',2,3),
		array('inventory','nonull','库存不能为空',2,3)
	
	);
	
	/**
	 * 添加
	 */
	
	public function addData(){
		if(!$this->create()) return FALSE;
//		p($_POST);
		$this->data['combine'] = $this->data['spec'];
		$this->data['goods_gid'] =$_POST['gid'];
		return $this->add();
	}
	
	
	/**
	 * 编辑
	 */
	public function editData($glid){
		if(!$this->create()) return FALSE;
//		p($_POST);
		$this->data['combine'] = $this->data['spec'];
		$this->data['goods_gid'] = $_POST['gid'];
		return $this->where("glid={$glid}")->update();
	}
	
	
}






 ?>